/**
 * Created by Administrator on 2017/7/4.
 */
import {getNewsList} from '../service/fetchFunction/fetchs'
import getRequest from '../service/fetch/api'
import * as types from './configs/type-mutation';
import axios from 'axios'


const getNewNotice = ({commit}, params)=> {
  getNewsList(params).then(res=> {
    commit(types.NEW_MSG, res)

  }).catch(err=> {

    console.log(err)

  })

}
//json测试数据；
const defultGetTestData = ({commit},params)=>{
  //getRequest.getTestDataList(params)
  //axios.get('../../static/data/newsList.json').then(function(res){
  //  //commit(type.NEW_DATA_LIST,{dataList:res,config:params});
  // console.log(res)
  //}).catch(function(err){
  //  //console.log(err)
  //})

 $.ajax({
   url:'../../static/data/newsList.json',
   type:'GET',
   dataType:'JSON',
   data:{},
   success:function(res){

     commit(types.NEW_DATA_LIST,{dataList:res,config:params})
     //console.log(res)
   },
   error:function(err){
     //console.log(err)
   }
 })

}


const getTest = ({commit}, params)=> {
  //console.log(params)
  commit(types.INFO_TEST, params)
}

const showTaost = ({commit}, params)=> {
  commit(types.SHOW_TAOST, params)
}
export default {
  getNewNotice,
  getTest,
  showTaost,
  defultGetTestData
}
